<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require 'isok.php';
require 'dbcon.php';
$title=$_REQUEST['title'];
$content=$_REQUEST['content'];
$slug=$_REQUEST['slug'];
$feature=$_REQUEST['feature'];
$category_id=$_REQUEST['category_id'];
date_default_timezone_set('Asia/Shanghai');
$created=date("Y-m-d h:i:s");
$status=$_REQUEST['status'];
$uid=$userinfo['id'];
$sql="INSERT INTO posts(title, content, slug, feature, category_id, created, status,user_id) VALUES( '{$title}', '{$content}', '{$slug}', '{$feature}', '{$category_id}', '{$created}', '{$status}',{$uid})";
$rs=$db->query($sql);//执行查询语句$sql，生成结果集$result
$db->close();//关闭数据库连接
if ($rs==true)
{
    header("Location:posts_html.php");
}
else   
{
    echo "<script type='text/javascript'>";  
    echo "alert('添加失败！');";
    echo "window.location.href='posts_html.php'";
    echo "</script>";
}
//require '../dbcon.php';
//$title=$_REQUEST['title'];
//$content=$_REQUEST['content'];
//$slug=$_REQUEST['slug'];
//$feature=$_REQUEST['feature'];
//$category_id=$_REQUEST['category_id'];
//date_default_timezone_set('Asia/Shanghai');
//$created=date("Y-m-d h:i:s");
//$status=$_REQUEST['status'];
//$sql="insert into posts(title,content,slug,feature,category_id,created,status) VALUES('{$title}','{$content}','{$slug}','{$feature}','{$category_id}','{$created}','{$status}')";
//$rs=$db->query($sql);
//$db->close();
//if($rs==true)
//{
//    echo "<script type='text/javascript'>";
//    echo "window.location.href='posts.php'";
//    echo "</script>";
//}
// else {
//    echo "<script type='text/javascript'>";
//    echo "alert('编辑失败！')";
//    echo "window.location.href='posts.php'";
//    echo "</script>";
//}


